package com.xd.oauth.controller;


import com.xd.auth.api.entity.OauthCode;
import com.xd.auth.api.feign.OauthCodeClient;
import com.xd.oauth.service.OauthCodeService;
import com.xd.common.base.BaseController;
import com.xd.common.model.R;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 授权所生成的code数据(OauthCode)表控制层
 *
 * @author hbx
 * @since 2020-10-24 15:47:22
 */
@RestController
@RequestMapping("oauthCode")
@Transactional(rollbackFor = Exception.class)
public class OauthCodeController extends BaseController<OauthCodeService, OauthCode,String> implements OauthCodeClient {

    @Resource
    private OauthCodeService OauthCodeService;

    @GetMapping("getUser")
    @ApiOperation("getUser")
    public R<String> getUser(){
        Authentication authentication = SecurityContextHolder.getContext()
                .getAuthentication();
        System.out.println(authentication.getPrincipal());
        return success("操作成功");
    }

}
